package com.example.aihub.repository;

import com.example.aihub.entity.Follow;
import com.example.aihub.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface FollowRepository extends JpaRepository<Follow, Long> {
    // 统计用户的粉丝数量
    int countByFollowed(User followed);
    
    // 统计用户关注的人数
    int countByFollower(User follower);
    
    // 检查用户是否已经关注了另一个用户
    boolean existsByFollowerAndFollowed(User follower, User followed);
    
    // 获取关注关系
    Optional<Follow> findByFollowerAndFollowed(User follower, User followed);
}